"""
@version:python3
@author:ll
@file:04-QWidget-案例-尺寸位置.py
@time:2022/2/9 19:45
"""
# 0、导入需要的包和模块
from PyQt5.Qt import *
import sys


# 1、创建一个应用程序对象
app = QApplication(sys.argv)

window = QWidget()
window.setWindowTitle("")
window.resize(500,500)
window.move(300,300)
window.show()

widget_count = 9 # 总控件个数
column_count = 3 # 一行多少列

widget_width = window.width() / column_count
row_count = widget_count // column_count + 1
widget_height = window.height() / row_count

for i in range(widget_count):
    w = QWidget(window)
    w.resize(widget_width,widget_height)
    widget_x = (i % column_count) * widget_width
    widget_y = (i // column_count) * widget_height
    w.move(widget_x,widget_y)
    w.setStyleSheet("background-color: red;border: 1px solid yellow;")
    w.show()



sys.exit(app.exec_())